package LeetCode.leetcode151;

import java.util.Locale;

public class Review2 {
    /**
     * 输入：s = "the   sky is blue"
     * 输出："blue is sky the"
     * @param s
     * @return
     */
    public String reverseWords(String s) {
        String[] handleData = s.split(" ");
        StringBuilder sb = new StringBuilder();
        for (int i = handleData.length - 1; i >= 0 ; i--) {
            String current = handleData[i].trim();
            if (!current.equals("")){
                sb.append(current+" ");
            }
        }
        return sb.toString().trim();
    }
}
